package app

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"testPaper/common"
	"testPaper/model"
	"testPaper/response"
)

// PracticeNumber 获取题目数量
func PracticeNumber(c *gin.Context) {
	DB := common.GetDB()
	paperId := c.PostForm("paperId")
	tag_id := c.PostForm("tag_id")
	var topic = make([]model.Topic, 0)
	var total int
	var single int
	var multiple int
	var judge int
	DB.Where("paper_id = ? ", paperId).Where("tag_id = ?", tag_id).Find(&topic).Count(&total)
	DB.Where("paper_id = ? And type = 'single'", paperId).Where("tag_id = ?", tag_id).Find(&topic).Count(&single)
	DB.Where("paper_id = ? And type = 'multiple'", paperId).Where("tag_id = ?", tag_id).Find(&topic).Count(&multiple)
	DB.Where("paper_id = ? And type = 'judge'", paperId).Where("tag_id = ?", tag_id).Find(&topic).Count(&judge)
	response.Reponse(c, http.StatusOK, 200, gin.H{"total": total, "single": single, "multiple": multiple, "judge": judge}, "ok")
	return
}
